﻿using PLCS.Application.Contracts.HisOrderApp.Dtos;
using PLCS.Application.Contracts.HisTaskApp.Dtos;
using PLCS.Client.IService.OrderTask;

using System.Collections.ObjectModel;

using Volo.Abp.Application.Dtos;

namespace PLCS.Client.Service.OrderTask;

public class HisOrderService : BaseService<HisOrderDto, HisOrderDto>, IHisOrderService
{
    public async Task<PagedResultDto<HisOrderDto>> GetListBySearchAsync(int skipCount, int maxResultCount, string? orderNo, string? startTime, string? endTime)
    {
        var route = $"hisOrder/bySearch?SkipCount={skipCount}&MaxResultCount={maxResultCount}";
        if (!string.IsNullOrEmpty(orderNo))
            route += $"&orderNo={orderNo}";
        if (!string.IsNullOrEmpty(startTime))
            route += $"&startTime={startTime}";
        if (!string.IsNullOrEmpty(endTime))
            route += $"&endTime={endTime}";
        RequestParam requestParam = new(method: Method.Get, route: route);
        var apiRes = await restClient.ExecuteAsync<PagedResultDto<HisOrderDto>>(requestParam);
        if (apiRes.Status)
            return apiRes.Data;
        else
            return new PagedResultDto<HisOrderDto>();
    }
}